﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

class CopyDirectory
{
    public static void CopyDir(DirectoryInfo source, DirectoryInfo target)
    {
        if (Directory.Exists(target.FullName) == false)
        {
            Directory.CreateDirectory(target.FullName);
        }

        foreach (var file in source.GetFiles())
        {
            file.CopyTo(Path.Combine(target.FullName, file.Name), true);
        }

        foreach (var dir in source.GetDirectories())
        {
            DirectoryInfo nextTarget = target.CreateSubdirectory(dir.Name);
            CopyDir(dir, nextTarget);
        }
    }

    static void Main(string[] args)
    {
        string sourceDir = @"C:\SomeFolder";
        string targetDic = @"C:\CopyOfSomeFolder";
        DirectoryInfo source = new DirectoryInfo(sourceDir);
        DirectoryInfo target = new DirectoryInfo(targetDic);
        CopyDir(source, target);
    }
}

